package com.eascs.web.o2o.report.entity;

import java.util.Date;

import com.eascs.app.runtime.RuntimeSetting;
import com.eascs.notify.sms.SmsNotifyRequest;
import com.eascs.notify.sms.SmsSendType;
import com.eascs.web.o2o.report.constants.FefundConstants;
import com.eascs.workflow.common.entity.sys.SysMessage;


/**
 * The persistent class for the wf_message database table.
 * 
 */

public class TransferO2OMessage {
	public static SysMessage transfer(O2OMessage from, SysMessage to){
		to.setMessageId(from.getMessageId());
		to.setContent(from.getContent());
		to.setCreateTime(from.getCreateTime());
		to.setReceiveName(from.getReceiveName());
		to.setReceiveTelphone(from.getReceiveTelphone());
		to.setSendType(from.getSendType());
		to.setSendName(from.getSendName());
		return to;
	}
	
	public static SmsNotifyRequest transferSms(O2OMessage from, SmsNotifyRequest smsCustomerRequest){
		RuntimeSetting runtimeSetting = RuntimeSetting.get();
		smsCustomerRequest.setRequestId(from.getRelevanceId());
		smsCustomerRequest.setBizCode(from.getLoanapplyno());
		smsCustomerRequest.setContent(from.getContent());
		smsCustomerRequest.setRecipientNumber(from.getReceiveTelphone());
		smsCustomerRequest.setRequestDateTime(new Date());
		if(!runtimeSetting.getEnv().equals(FefundConstants.ENV_PROD)){ //如果不是正式环境默认短信已经发送
			smsCustomerRequest.setSmsSendType(SmsSendType.TEST);
		}else{
			smsCustomerRequest.setSmsSendType(SmsSendType.GENERAL);
		}
		smsCustomerRequest.setSystemCode("业务系统");
		smsCustomerRequest.setReceiveName(from.getReceiveName());
		smsCustomerRequest.setSendName(FefundConstants.SENDNAME);
		return smsCustomerRequest;
	}

}